package com.imooc.dto.user;

import com.imooc.common.constants.ResultCodeConstants;
import com.imooc.common.exception.ValidateException;
import com.imooc.common.result.AbstractRequest;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * @ClassName: UserLoginRequest
 * @Description:
 * @author: limingxing
 * @Date: 2019-12-24 10:34
 */
@Data
@ApiModel(value = "用户登录请求参数")
public class UserLoginRequest extends AbstractRequest {
    @ApiModelProperty(value = "用户名", name = "username", example = "imooc", required = true)
    private String username;
    @ApiModelProperty(value = "密码", name = "password", example = "123456", required = true)
    private String password;

    @Override
    public void requestCheck() {
        if (StringUtils.isBlank(username) ||
                StringUtils.isBlank(password)) {
            throw new ValidateException(ResultCodeConstants.REQUISITE_PARAMETER_NOT_EXIST.getCode(),
                    "用户和密码不能为空");
        }
    }
}
